//
//  KBMoreListenCell.m
//  喜马拉雅改良版框架
//
//  Created by dllo on 15/12/31.
//  Copyright © 2015年 蓝鸥科技. All rights reserved.
//

#import "KBMoreListenCell.h"

@implementation KBMoreListenCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        [self createSubViews];
    }
    return self;
}

- (void)createSubViews
{
    
    // 图片
    _coverPathSmall = [[UIImageView alloc] init];
    [self.contentView addSubview:_coverPathSmall];
    [_coverPathSmall mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(8);
        make.bottom.mas_equalTo(-8);
        make.left.mas_equalTo(10);
        make.width.mas_equalTo(70);
        
    }];
    // 标题
    _title = [[UILabel alloc] init];
    _title.font = [UIFont systemFontOfSize:16];
    [self.contentView addSubview:_title];
    [_title mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(_coverPathSmall.mas_top);
        make.left.equalTo(_coverPathSmall.mas_right).offset(8);
        make.width.mas_equalTo(230);
        make.height.mas_equalTo(20);
        
    }];
    // 内容
    _subtitle = [[UILabel alloc] init];
    _subtitle.font = [UIFont systemFontOfSize:14];
    _subtitle.textColor = [UIColor colorWithRed:0.59 green:0.59 blue:0.59 alpha:1];
    [self.contentView addSubview:_subtitle];
    [_subtitle mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(_title.mas_bottom).offset(5);
        make.left.equalTo(_title.mas_left);
        make.width.mas_equalTo(250);
        make.height.mas_equalTo(18);
        
    }];
    
    // 播放次数(图)
    UIImageView *playtime = [[UIImageView alloc] init];
    playtime.image = [UIImage imageNamed:@"find_specialicon@2x.png"];
    [self.contentView addSubview:playtime];
    [playtime mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(_subtitle.mas_bottom).offset(12);
        make.left.mas_equalTo(_subtitle.mas_left).offset(3);
        make.width.mas_equalTo(12);
        make.height.mas_equalTo(12);
    }];
    
    // 播放次数
    _footnote = [[UILabel alloc] init];
    _footnote.font = [UIFont systemFontOfSize:13];
    _footnote.textColor = [UIColor colorWithRed:0.64 green:0.64 blue:0.64 alpha:1];
    [self.contentView addSubview:_footnote];
    [_footnote mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(playtime.mas_top).offset(-5);
        make.left.mas_equalTo(playtime.mas_right).offset(5);
        make.width.mas_equalTo(60);
        make.height.mas_equalTo(20);
        
    }];

}

- (void)setModel:(KBMoreListenModel *)model
{
    NSURL *url = [NSURL URLWithString:model.coverPathSmall];
    [_coverPathSmall sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:ImagePlaceHolder]];
    
    _title.text = model.title;
    _subtitle.text = model.subtitle;
    _footnote.text = model.footnote;
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
